import { createRouter, createWebHistory } from 'vue-router'
import HomeView from "@/views/HomeView.vue";
import AnswerQuestionView from "@/views/answer/AnswerQuestionView.vue";
import QuestionBankView from "@/views/QuestionBankView.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AnswerResultView from "@/views/answer/AnswerResultView.vue";
import UserProfileView from "@/views/userProfile/UserProfileView.vue";
import UserPublishPostView from "@/views/userProfile/UserPublishPostView.vue";
import UserFavourPostView from "@/views/userProfile/UserFavourPostView.vue";
import UserFinishBankView from "@/views/userProfile/UserFinishBankView.vue";
import AdminHomeView from "@/views/admin/AdminHomeView.vue";
import AdminPostView from "@/views/admin/AdminPostView.vue";
import AdminBankInfoView from "@/views/admin/AdminBankInfoView.vue";
import AdminBankQuestionView from "@/views/admin/AdminBankQuestionView.vue";
import AdminAnswerView from "@/views/admin/AdminAnswerView.vue";
import AdminUserInfoView from "@/views/admin/AdminUserInfoView.vue";
import OtherProfileView from "@/views/userProfile/OtherProfileView.vue";
import OtherPublishPostView from "@/views/userProfile/OtherPublishPostView.vue";
import OtherFavourPostView from "@/views/userProfile/OtherFavourPostView.vue";
import StudyView from "@/views/StudyView.vue";

export const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: '主页',
        component: HomeView,
        meta:{
            menu: 'home'
        }
    },
    {
        path: '/questionBank',
        name: '题库',
        component: QuestionBankView,
        meta:{
            menu: 'home'
        }
    },
    {
        path: '/study',
        name: '学习',
        component: StudyView,
        meta:{
            menu: 'home'
        }
    },
    {
        path: '/answerQuestion/:bankId',
        name: '答题',
        component: AnswerQuestionView,
    },
    {
        path: '/answerResult/:answerId',
        name: '答题结果',
        component: AnswerResultView,
    },
    {
        path: '/userProfile',
        name: '个人中心',
        component: UserProfileView,
        children: [
            {
                path: 'myPost',
                name: '我的发布',
                component: UserPublishPostView,
            },
            {
                path: 'myFavour',
                name: '我的收藏',
                component: UserFavourPostView
            },
            {
                path: 'myFinish',
                name: '已完成',
                component: UserFinishBankView
            }
        ],
    },
    {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
    },
    {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView
    },
    {
        path: "/admin/home",
        name: "系统总览",
        component: AdminHomeView
    },
    {
        path: "/admin/post",
        name: "系统总览",
        component: AdminPostView
    },
    {
        path: "/admin/bankInfo",
        name: "题库信息管理",
        component: AdminBankInfoView
    },
    {
        path: "/admin/bankQuestion",
        name: "题库内容管理",
        component: AdminBankQuestionView
    },
    {
        path: "/admin/answer",
        name: "作答记录管理",
        component: AdminAnswerView
    },
    {
        path: "/admin/userInfo",
        name: "用户信息管理",
        component: AdminUserInfoView
    },
    {
        path: "/otherProfile/:userId",
        name: "其它用户个人主页",
        component: OtherProfileView,
        children: [
            {
                path: 'otherPost/:userId',
                name: '他的发布',
                component: OtherPublishPostView,
            },
            {
                path: 'otherFavour/:userId',
                name: '他的收藏',
                component: OtherFavourPostView
            }
        ],
    }
]

// 目前就这么写
const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});

export default router